function DriverCtrl($scope, $http, $cookieStore) {
	$scope.DRIVER_TYPE = DRIVER_TYPE;
	$scope.DRIVER_ALGORITHM = DRIVER_ALGORITHM;
	
	Pagination.initialize("/driver/findPage", $scope, $http, 15);
	
	$scope.storeCookie = function() {
		$cookieStore.put("formCondition", $scope.formCondition);
	};
	
	$scope.createDriver = function () {
		$scope.storeCookie();
		window.location.href = "/driver/add";
	};
	
	$scope.editDriver = function (driver) {
		$scope.storeCookie();
		window.location.href = "/driver/edit/" + driver.id;
	};
	
	$scope.deleteDriver = function (driver) {
		Message.confirm("确认", "确认要删除驱动“" + driver.name + "”？", function () {
			$http.post("/driver/delete/" + driver.id).success(function (response) {
				if (response.success) {
					$scope.search();
				} else {
					Message.error("错误", response.message || "删除失败！");
				}
			});
		});
	};
	
	$scope.init = function() {
		if (QUERY_COOKIE === 'true') {
			$scope.formCondition = $cookieStore.get("formCondition");
		} else {
			$scope.formCondition = {};
		}
		
		$scope.search();
	};
 
	$scope.init();
};

app.controller('DriverCtrl', DriverCtrl);